package objectsDiagram;

import java.util.LinkedList;
import java.util.Vector;

public class Task extends State implements Cloneable{

	private boolean isComposite;
	private boolean isCanceller;
	private LinkedList<String> removesToken;
	
	public Task(){
		super();
		removesToken = new LinkedList<String>();
		isComposite = false;
	}

	public boolean isComposite() {
		return isComposite;
	}

	public void setComposite(boolean isComposite) {
		this.isComposite = isComposite;
	}
	
	public Task clone(){
		Task task = new Task();
		try {
			task = (Task) super.clone();
			Vector<Flow> newFlowsIn = new Vector<Flow>();
			Vector<Flow> newFlowsOut = new Vector<Flow>();
			for(int i=0;i<this.getFlowsIn().size();i++){
				newFlowsIn.add(this.getFlowsIn().get(i).clone());
			}
			for(int i=0;i<this.getFlowsOut().size();i++){
				newFlowsOut.add(this.getFlowsOut().get(i).clone());
			}
			task.setFlowsIn(newFlowsIn);
			task.setFlowsOut(newFlowsOut);
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		task.setComposite(isComposite);
		return task;
	}
	

	public void setCanceller(boolean isCanceller) {
		this.isCanceller = isCanceller;
	}
	
	public boolean isCanceller(){
		return isCanceller;
	}

	public void addRemoveToken(String id) {
		this.removesToken.add(id);
	}
	
	public LinkedList<String> getListTokens(){
		return removesToken;
	}

	public String toString() {
		return "Task [" + super.toString() + "  isComposite=" + isComposite + "]";
	}	
}
